package com.xh.demo.controller;

import com.xh.demo.domain.po.User;
import com.xh.demo.domain.vo.AJAXResult;
import com.xh.demo.domain.vo.UserVo;
import com.xh.demo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Name TestController
 * @Description
 * @Author wen
 * @Date 2019-07-31
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @GetMapping("/view")
    public String view(){
        return "user";
    }

    @GetMapping("/list")
    @ResponseBody
    public AJAXResult<List<User>> user(){
        return AJAXResult.success(userService.getAll());
    }

    @GetMapping("/add")
    public String addUserView(){
        return "user_add";
    }

    @PostMapping("/add")
    @ResponseBody
    public String addUser(UserVo userVo){
        return "success:" + userVo;
    }


}
